import { createRouter, createWebHashHistory } from 'vue-router'
// @ts-ignore
import { constantRoute } from './routes'
// 创建路由器
const router = createRouter({
    // 路由模式hash
    history: createWebHashHistory(),
    // @ts-ignore
    routes: constantRoute,
    //滚动行为
    scrollBehavior() {
        return {
            left: 0,
            top: 0,
        }
    },
})


// 设置默认路由为 /login
router.beforeEach((to, from, next) => {
    if (to.path === '/') {
        next('/login');
    } else {
        next();
    }
});
export default router